package weeny.kdtree.pre;

import java.awt.geom.Point2D;

import prefuse.data.Graph;
import prefuse.data.Table;
import prefuse.data.Tuple;
import weeny.pre.util.Geom;

public class KdTreeUtil extends weeny.kdtree.KdTreeUtil{
	private Point2D temp = new Point2D.Double();
	@Override
	protected double[] toArray(Object node) {
		if (node instanceof Point2D || node instanceof Tuple) {
			Geom.dumpPnt(node, temp);
			return new double[]{temp.getX(), temp.getY()};	
		}
		else{
			return super.toArray(node);
		}
	}
	public void addGraphNodes(Graph g){
		super.addIterator(g.nodes());
	}
	public void addTuples(Table t){
		super.addIterator(t.tuples());
	}
}
